import 'package:flutter/material.dart';
import 'package:flutter_app1/pages/checkbox.dart';
import 'package:flutter_app1/pages/cupertinoDatePicker.dart';
import 'package:flutter_app1/pages/tabs.dart';
import 'package:flutter_swiper/flutter_swiper.dart';
import '../pages/tabs.dart';
import '../pages/search.dart';
import '../pages/form.dart';
import '../pages/productDetail.dart';
import '../pages/user/login.dart';
import '../pages/user/registerFirst.dart';
import '../pages/user/registerSecond.dart';
import '../pages/appbarDemo.dart';
import '../pages/tabController.dart';
import '../pages/user/user.dart';
import '../pages/button.dart';
import '../pages/textField.dart';
import '../pages/radio.dart';
import '../pages/formDemo.dart';
import '../pages/datePicker.dart';
import '../pages/swiper.dart';
import '../pages/dialog.dart';
import '../pages/http.dart';

final routes = {
  '/': (context) => Tabs(),
  '/form': (context) => FormPage(),
  '/search': (context, {arguments}) => SearchPage(arguments:arguments),
  '/productDetails': (context, {arguments}) => ProductDetailsPage(arguments:arguments),
  '/login': (context) => Login(),
  '/registerFirst': (context) => RegisterFirst(),
  '/registerSecond': (context) => RegisterSecond(),
  '/appbarDemo': (context) => AppBarDemoPage(),
  '/tabController': (context) => TabControllerPage(),
  '/userCenter': (context) => UserCenterPage(),
  '/buttons': (context) => ButtonsPage(),
  '/textField': (context) => TextFieldPage(),
  '/checkbox': (context) => CheckBoxPage(),
  '/radio': (context) => RadioPage(),
  '/formDemo': (context) => FormDemoPage(),
  '/datePickerPage': (context) => DatePickerPage(),
  '/cupertinoDatePickerPage': (context) => CupertionDatePickerPage(),
  '/swiperPage': (context) => SwiperPage(),
  '/alertDialogPage': (context) => AlertDialogPage(),
  '/httpPage': (context) => HttpPage(),
};

// 固定写法。统一处理
var onGenerateRoute = (RouteSettings settings) {
  final String name = settings.name;
  final Function pageContentBuilder = routes[name];
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route = MaterialPageRoute(
          builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};